package com.face.facerecognition.vo;


import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.springframework.boot.jackson.JsonObjectSerializer;

@Data
public class ResultVo {
    //生成ResultVo的字段以及方法
    private Integer code;
    private String msg;
    private Object data;

    // 无参构造函数
    public ResultVo() {}

    // 带参数的构造函数
    public ResultVo(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    // 带参数的构造函数，包含数据
    public ResultVo(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    // 成功时的静态方法
    public static ResultVo success() {
        return new ResultVo(200, "Success");
    }

    // 成功时的静态方法，包含数据
    public static ResultVo success(Object data) {
        return new ResultVo(200, "Success", data);
    }

    // 错误时的静态方法
    public static ResultVo error(String msg) {
        return new ResultVo(500, msg);
    }

    // 错误时的静态方法，自定义错误码
    public static ResultVo error(Integer code, String msg) {
        return new ResultVo(code, msg);
    }

}
